<?php
class Software extends Riskle_Db_Table
{
    protected $_name = 'softwares';
    
    protected $_parentMap = array(
       'categories' => array(
           'local'     => 'category_id',
           'remote'    => 'id',
           'fields'    => array('name as cname', 'search_id')
       )
    );
    
    
    public function getMaxSort($categoryId)
    {
        $tableName = $this->_db->quoteIdentifier($this->_name);
        $sql = "
            SELECT MAX(sort_id) 
            FROM $tableName 
            WHERE $tableName.category_id='$categoryId'
        ";
        $maxSortId = $this->_db->fetchOne($sql);
        return $maxSortId;
    }
}
